const pathToRegexp = require("path-to-regexp");

let url = "/user/:id/:name";
let requestUrl = "/user/1/2";
let params = [];
let reg1 = pathToRegexp(url, params)
console.log(reg1, params);

let keys = [];
url = url.replace(/:([^\/]+)/g, function () {
  keys.push(arguments[1]);
  return "([^/]+)";
});
console.log(url, keys);

let reg = new RegExp(url);
let [, ...args] = requestUrl.match(reg);
console.log(args);
